package com.ruoyi.ai.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ai.mapper.SysAiTasksMapper;
import com.ruoyi.ai.domain.SysAiTasks;
import com.ruoyi.ai.service.ISysAiTasksService;

/**
 * AI任务Service业务层处理
 *
 * @author yaolei
 * @date 2024-06-25
 */
@Service
public class SysAiTasksServiceImpl implements ISysAiTasksService
{
    @Autowired
    private SysAiTasksMapper sysAiTasksMapper;

    /**
     * 查询AI任务
     *
     * @param id AI任务主键
     * @return AI任务
     */
    @Override
    public SysAiTasks selectSysAiTasksById(Long id)
    {
        SysAiTasks sysAiTasksTmp = sysAiTasksMapper.selectSysAiTasksById(id);
        String taskCreator = sysAiTasksTmp.getTaskCreator()
                .replaceAll("wm4EHiUAAAJS6XMwMQ-Au2NDmixKjvQA","王昊")
                .replaceAll("wm4EHiUAAAqDgcBtL0Lme6PFUwg2wxlw","sisi")
                .replaceAll("zhangliang","张亮")
                ;
        sysAiTasksTmp.setTaskCreator(taskCreator);


        if(sysAiTasksTmp.getRoomid() != null){
            String roomid = sysAiTasksTmp.getRoomid()
                    .replaceAll("wr4EHiUAAATeLfHYbnWi8CqMFTGj0mIg", "燥物中台沟通群")
                    ;
            sysAiTasksTmp.setRoomid(roomid);
        }

        return sysAiTasksTmp;//sysAiTasksMapper.selectSysAiTasksById(id);
    }

    /**
     * 查询AI任务列表
     *
     * @param sysAiTasks AI任务
     * @return AI任务
     */
    @Override
    public List<SysAiTasks> selectSysAiTasksList(SysAiTasks sysAiTasks)
    {
        List<SysAiTasks> sysAiTasksList = sysAiTasksMapper.selectSysAiTasksList(sysAiTasks);

        /*
        for(int i = 0; i < sysAiTasksList.size(); i++){
            SysAiTasks sysAiTasksTmp = sysAiTasksList.get(i);

            String taskCreator = sysAiTasksTmp.getTaskCreator()
                    .replaceAll("wm4EHiUAAAJS6XMwMQ-Au2NDmixKjvQA","王昊")
                    .replaceAll("wm4EHiUAAAqDgcBtL0Lme6PFUwg2wxlw","sisi")
                    .replaceAll("zhangliang","张亮")
                    ;
            sysAiTasksTmp.setTaskCreator(taskCreator);


            if(sysAiTasksTmp.getRoomid() != null){
                String roomid = sysAiTasksTmp.getRoomid()
                    .replaceAll("wr4EHiUAAATeLfHYbnWi8CqMFTGj0mIg", "燥物中台沟通群")
                ;
                sysAiTasksTmp.setRoomid(roomid);
            }

        }*/

        return sysAiTasksList;
    }


    public List<SysAiTasks> selectSysAiTasksListWithNoNull(SysAiTasks sysAiTasks)
    {
        List<SysAiTasks> sysAiTasksList = sysAiTasksMapper.selectSysAiTasksListWithNoNull(sysAiTasks);

        /*
        for(int i = 0; i < sysAiTasksList.size(); i++){
            SysAiTasks sysAiTasksTmp = sysAiTasksList.get(i);

            String taskCreator = sysAiTasksTmp.getTaskCreator()
                    .replaceAll("wm4EHiUAAAJS6XMwMQ-Au2NDmixKjvQA","王昊")
                    .replaceAll("wm4EHiUAAAqDgcBtL0Lme6PFUwg2wxlw","sisi")
                    .replaceAll("zhangliang","张亮")
                    ;
            sysAiTasksTmp.setTaskCreator(taskCreator);


            if(sysAiTasksTmp.getRoomid() != null){
                String roomid = sysAiTasksTmp.getRoomid()
                        .replaceAll("wr4EHiUAAATeLfHYbnWi8CqMFTGj0mIg", "燥物中台沟通群")
                        ;
                sysAiTasksTmp.setRoomid(roomid);
            }

        }*/

        return sysAiTasksList;
    }

    /**
     * 新增AI任务
     *
     * @param sysAiTasks AI任务
     * @return 结果
     */
    @Override
    public int insertSysAiTasks(SysAiTasks sysAiTasks)
    {
        return sysAiTasksMapper.insertSysAiTasks(sysAiTasks);
    }

    /**
     * 修改AI任务
     *
     * @param sysAiTasks AI任务
     * @return 结果
     */
    @Override
    public int updateSysAiTasks(SysAiTasks sysAiTasks)
    {
        return sysAiTasksMapper.updateSysAiTasks(sysAiTasks);
    }

    /**
     * 批量删除AI任务
     *
     * @param ids 需要删除的AI任务主键
     * @return 结果
     */
    @Override
    public int deleteSysAiTasksByIds(Long[] ids)
    {
        return sysAiTasksMapper.deleteSysAiTasksByIds(ids);
    }

    /**
     * 删除AI任务信息
     *
     * @param id AI任务主键
     * @return 结果
     */
    @Override
    public int deleteSysAiTasksById(Long id)
    {
        return sysAiTasksMapper.deleteSysAiTasksById(id);
    }
}
